package com.hebo.testdemo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hebo.testdemo.model.TUser;
import com.hebo.testdemo.mapper.TUserMapper;
import com.hebo.testdemo.service.ITUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author test
 * @since 2021-08-05
 */
@Service
public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements ITUserService {

    @Resource
    private TUserMapper tUserMapper;

    @Override
    public TUser login(TUser tUser) {
        TUser tUser1 = tUserMapper.selectOne(new LambdaQueryWrapper<TUser>().eq(TUser::getUsername, tUser.getUsername()));
        System.out.println(tUser1);
        if (tUser1 != null && tUser1.getPassword().equals(tUser.getPassword())) {
            return tUser1;
        }else {
            return null;
        }
    }
}
